<include file="Public/min-header" />
<script type="text/javascript">
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$URL_upload}";
    var URL_fileUp = "{$URL_fileUp}";
    var URL_scrawlUp = "{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$URL_getRemoteImage}";
    var URL_imageManager = "{$URL_imageManager}";
    var URL_imageUp = "{$URL_imageUp}";
    var URL_getMovie = "{$URL_getMovie}";
    var URL_home = "{$URL_home}";
</script>
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.config.js"/>
<load href="__ROOT__/Public/plugins/Ueditor/ueditor.all.js"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>



<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            </div>
            <div class="panel panel-default">           
                <div class="panel-body ">   
                   	<ul class="nav nav-tabs">
                        <foreach name="group_list" item="vo" key="k">
                     		<li <if condition="$k eq 'about'">class="active"</if>><a href="javascript:void(0)" data-url="{:U('System/index',array('inc_type'=>$k))}" data-toggle="tab" onclick="goset(this)">{$vo}</a></li>
                     	</foreach>                        
                    </ul>
                    <!--表单数据-->
                    <form method="post" id="handlepost" action="{:U('System/handle')}">                    
                        <!--通用信息-->
                    <div class="tab-content" style="padding:20px 0px;">                 	  
                        <div class="tab-pane active" id="tab_smtp">                           
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td class="col-sm-2">关于我们标题：</td>
                                    <td class="col-sm-8">
                                        <input type="text" class="form-control" name="about_title" value="{$config.about_title}" >
                                    </td>
                                </tr>


                                <tr>
                                    <td class="col-sm-2">关于我们内容：</td>
                                    <td class="col-sm-8">

                                        <textarea class="span12 ckeditor" id="post_content" name="about_content" title="">{$config.about_content}</textarea>


                                        <!--<input type="text" class="form-control" name="about_title" value="{$config.about_title}" >-->
                                    </td>
                                </tr>

                                </tbody> 
                                <tfoot>
                                	<tr>
                                	<td><input type="hidden" name="inc_type" value="{$inc_type}"></td>
                                	<td class="text-right"><input class="btn btn-primary" type="button" onclick="adsubmit()" value="保存"></td></tr>
                                </tfoot>                               
                                </table>
                        </div>                           
                    </div>              
			    	</form><!--表单数据-->
                </div>
            </div>
        </div>
    </section>
</div>
<script>


    var editor;
    $(function () {
        //具体参数配置在  editor_config.js 中
        var options = {
            zIndex: 999,
            initialFrameWidth: "100%", //初化宽度
            initialFrameHeight: 350, //初化高度
            focus: false, //初始化时，是否让编辑器获得焦点true或false
            wordCount:true,
            maximumWords: 199999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
            pasteplain: true, autoHeightEnabled: true,
            autotypeset: {
                mergeEmptyline: true,        //合并空行
                removeClass: true,           //去掉冗余的class
                removeEmptyline: false,      //去掉空行
                textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
                imageBlockLine: 'center',    //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
                pasteFilter: false,          //根据规则过滤没事粘贴进来的内容
                clearFontSize: false,        //去掉所有的内嵌字号，使用编辑器默认的字号
                clearFontFamily: false,      //去掉所有的内嵌字体，使用编辑器默认的字体
                removeEmptyNode: false,      //去掉空节点
                removeTagNames: {"font": 1},
                indent: false,               // 行首缩进
                indentValue: '0em'           //行首缩进的大小
            },
            toolbars: [
                ['fullscreen', 'source', '|', 'undo', 'redo','|', 'bold', 'italic', 'underline', 'fontborder',
                    'strikethrough', 'superscript', 'subscript','removeformat', 'formatmatch', 'autotypeset',
                    'blockquote', 'pasteplain', '|', 'forecolor','backcolor', 'insertorderedlist',
                    'insertunorderedlist', 'selectall', 'cleardoc', '|','rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize','|', 'directionalityltr', 'directionalityrtl',
                    'indent', '|', 'justifyleft', 'justifycenter','justifyright', 'justifyjustify', '|', 'touppercase',
                    'tolowercase', '|', 'link', 'unlink', 'anchor', '|','imagenone', 'imageleft', 'imageright', 'imagecenter',
                    '|', 'insertimage', 'emotion', 'insertvideo','attachment', 'map', 'gmap', 'insertframe',
                    'insertcode', 'webapp', 'pagebreak', 'template','background', '|', 'horizontal', 'date', 'time',
                    'spechars', 'wordimage', '|','inserttable', 'deletetable','insertparagraphbeforetable', 'insertrow', 'deleterow',
                    'insertcol', 'deletecol', 'mergecells', 'mergeright','mergedown', 'splittocells', 'splittorows',
                    'splittocols', '|', 'print', 'preview', 'searchreplace']
            ]
        };
        editor = new UE.ui.Editor(options);
        editor.render("post_content");
    });

    $('input[type="radio"]').click(function(){
        if($(this).val() == 0){
            $('.timed').hide();
        }else{
            $('.timed').show();
        }
    })



    function adsubmit(){
        var submitcateidval =$(":radio[name='cateid']:checked").val();

/*

        if($('#name').val() ==''){
            alert('优惠名称不能为空');
            return false;
        }

        if(submitcateidval==1)
        {
            if($('input[name=money]').val() =='' || $('input[name=condition]').val() ==''){
                alert('优惠券面额及消费金额不能为空');
                return false;
            }
        }
        else if(submitcateidval==2)
        {

            if($('input[name=expression]').val() ==''){

                alert('折扣优惠不能为空');
                return false;
            }
        }
        else if(submitcateidval==3)
        {

            if($('input[name=money]').val() ==''){

                alert('优惠券面额不能为空');
                return false;
            }
*/

//			var pg = [];
//			//过滤选择重复商品
//			$('input[name*="goods_id"]').each(function(i,o){
//				pg.push($(o).val());
//			});
//			if(pg.length==0){
//
//				alert('请指定现金券对应商品');
//				return false;
//			}
        }

        $('#coupon').submit();
    }


    $(":radio[name='cateid']").click(function(){
        var cateidval =$(":radio[name='cateid']:checked").val();
        if(cateidval==1)
        {
            $('.coupon_sec1,.coupon_sec3').show();
            $('.coupon_sec2,.coupon_sec4').hide();
        }
        else if(cateidval==2)
        {
            $('.coupon_sec2').show();
            $('.coupon_sec1,.coupon_sec3,.coupon_sec4').hide();
        }
        else if(cateidval==3)
        {

//			 $('.coupon_sec4,.coupon_sec1').show();
            $('.coupon_sec1').show();
            $('.coupon_sec2,.coupon_sec3').hide();
        }


    });

    function call_back01(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
        $("#original_img2").attr('href', fileurl_tmp);
    }

    $(function(){
        data_pick('send_start_time');
        data_pick('send_end_time');
        data_pick('use_start_time');
        data_pick('use_end_time');
        $('input[type="radio"]:checked').trigger('click');
    })


    function selectGoods(){
        var goods_id = [];
        //过滤选择重复商品
        $('input[name*="goods_id"]').each(function(i,o){
            goods_id.push($(o).val());
        });
        var url = '/index.php?m=Admin&c=Coupon&a=search_coupon_goods&goods_id='+goods_id+'&t='+Math.random();
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.3,
            area: ['70%', '80%'],
            content: url,
        });
    }



    function call_back(table_html)
    {
        layer.closeAll('iframe');
        $('#goods_list').append(table_html);
    }

    function data_pick(id){
        var myDate = new Date();
        $('#'+id).daterangepicker({
            format:"YYYY-MM-DD HH:mm:ss",
            singleDatePicker: true,
            showDropdowns: true,
            minDate:myDate.getFullYear()+'-'+myDate.getMonth()+'-'+myDate.getDate(),
            maxDate:'2030-01-01',
            timePicker : true, //是否显示小时和分钟
            timePickerIncrement:1,//time选择递增数
            timePicker12Hour : false, //是否使用12小时制来显示时间
            locale : {
                applyLabel : '确定',
                cancelLabel : '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1
            }
        });
    }
</script>
<script>
var flag = true;
function adsubmit(){
	check_form();
	if(flag){
		$('#handlepost').submit();
	}
}

function check_form(){
//	if($('input[name="smtp_server"]').val() == ''){
//		alert('请填写邮件发送服务器地址');
//		flag = false;
//		return;
//	}
//	if($('input[name="smtp_user"]').val() == '' || !checkEmail($('input[name="smtp_user"]').val())){
//		alert('请填写正确的邮箱账号');
//		flag = false;
//		return;
//	}
//	if($('input[name="smtp_pwd"]').val() == ''){
//		alert('请填写发送邮箱密码');
//		flag = false;
//		return;
//	}
}

$(document).ready(function(){
	get_province();
});

function goset(obj){
	window.location.href = $(obj).attr('data-url');
}

function sendEmail(){
	if($('input[name="test_eamil"]').val() == '' || !checkEmail($('input[name="test_eamil"]').val())){
		alert('请填写正确的测试邮箱账号');
		return;
	}else{
		$.ajax({
			type : "post",
			data : $('#handlepost').serialize(),
			dataType : 'json',
			url : "{:U('System/send_email')}",
			success : function(res){
				if(res==1){
					layer.msg('发送成功', {icon: 1});
				}else{
					layer.msg('发送失败', {icon: 2,time: 2000});
				}
			}
		})
	}
}
</script>
</body>
</html>